home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9130 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  48 lines

  1. Path: news.Stanford.EDU!not-for-mail
  2. From: iburrell@leland.Stanford.EDU (Ian Burrell)
  3. Newsgroups: comp.lang.c++,gnu.g++.help
  4. Subject: Forward declarations of typedefs
  5. Date: 28 Feb 1996 12:56:25 -0800
  6. Organization: Stanford University
  7. Message-ID: <4h2fhp$si8@elaine22.Stanford.EDU>
  8. NNTP-Posting-Host: elaine22.stanford.edu
  9.  
  10. I am trying to do a forward declaration of a type defined in another
  11. header so that I can make a class member that is a pointer.  However,
  12. if the forward declaration type is later defined as a typedef, I get
  13. lots of errors.
  14.  
  15. Is there a way to consistently make forward declarations that works
  16. with later typedefs?  Does the method work if the type representation
  17. later changes?  How about anonymous structs defined in a typedef?
  18.  
  19. Here is a snippet of example code and the errors it gives:
  20.  
  21. struct test;
  22.  
  23. test* t;
  24.  
  25. struct _test
  26. {
  27.     int a;
  28. };
  29.  
  30. typedef _test test;
  31.  
  32. typedef.cc:15: conflicting types for `struct _test'
  33. typedef.cc:15: previous declaration as `struct test'
  34. typedef.cc: In function `int main()':
  35. typedef.cc:20: type `test' is not a base type for type `_test'
  36. typedef.cc:21: invalid use of undefined type `struct test'
  37. typedef.cc:23: invalid use of undefined type `struct test'
  38.  
  39.  
  40.  - Ian
  41.  
  42.  
  43. -- 
  44.           -- Ian Burrell == iburrell@leland.stanford.edu **
  45.            <URL:http://www-leland.stanford.edu/~iburrell/>
  46. Zymurgy's Law of Volunteer Labor: 
  47.     People are always available for work in the past tense.
  48.